<?php 
namespace app\common\model;
use think\Model;
use app\common\model\Resume as ResumeModel;
class ResumeBrowse extends Model
{
	public static function saveBrowse($company_id,$id):void
	{
		if ($company_id && $id){
			$Find=self::where(['resume_id'=>$id,'company_id'=>$company_id])->find();
			if (!$Find) {
				$ResumeBrowseModel=new self;
				$ResumeBrowseModel->company_id=$company_id;
				$ResumeBrowseModel->resume_id=$id;
				$ResumeBrowseModel->save();
			}else if ($Find->company_delete_time) {
				$Find->company_delete_time=null;
				$Find->save();
			}
		}
		self::setIncView($id);
	}
	public static function setIncView($id):void
	{
        $view_rand=intval(config('basic.view_rand'));
        $view=1;
        if ($view_rand)
        $view=rand(1,$view_rand);
		if ($id) ResumeModel::where(['id'=>$id])->inc('view',$view)->update();
	}
}